#ifndef FEATURE_INDEX_H
#define FEATURE_INDEX_H
#include <vector>
#include <string>
#include <map>
//#include "tagger.h"
const static std::string START_SYM = "START";
const static std::string END_SYM = "END"; 
namespace MRFPP {
class Tagger;
class FeatureIndex
{
	private:

		bool useSuffixFeatures;
		bool useHasHyphen;
		int suffixLength;
		int maxid_;
		int maxtagid_;
		std::vector<double>& alpha_;
		//unsigned int xsize_;
		//unsigned int ysize_;
		std::vector <std::vector <std::string> > data_;
		std::vector <std::vector <int> >answers_;
		std::vector <std::string> y_;
		std::vector <std::string> tag_;
		std::map <std::string, std::pair<int, int> > dic_;
		std::map <std::string, int> tagdic_;
		std::vector <int> length;
	public:
		FeatureIndex(std::vector <double>& alpha):maxid_(0),maxtagid_(0),suffixLength(2),useHasHyphen(false),useSuffixFeatures(false),alpha_(alpha){}
		std::vector <std::vector <int> > feature_cache_;
		size_t size() const { return maxid_; }
		size_t ysize() const { return y_.size(); }
		size_t xsize(int n) const { return length[n];}
		void set_alpha(std::vector<double>& alpha) { alpha_ = alpha;}
		std::vector <double>& get_alpha() { return alpha_;}
		void extractWordFeature(std::string);
		//void extractEdgeFeature(std::string, std::string);
		void extractEdgeFeature();
		bool open(const char*, bool);
		bool openFeatures(bool, std::vector <Tagger*>&);
		void getFeatures(Tagger*, std::vector <std::string>& , std::vector<int>&);

		int addFeature(std::string, bool isEdge);
		int getTagID(std::string);
		int TagID(std::string);
		std::string getTag(int id) { return tag_[id];}
		void buildFeatures(Tagger *);
		void update(Tagger*);
};
}
#endif
